home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / MarsEdit 1.0.dmg / MarsEdit.app / Contents / Resources / MEPingSites.m < prev    next >
Encoding:
Text File  |  2004-12-10  |  1.7 KB  |  86 lines

  1. /*
  2.     MEPingSites.m
  3.     MarsEdit
  4.  
  5.     Created by Brent Simmons on 11/9/04.
  6.     Copyright 2004 Ranchero Software. All rights reserved.
  7. */
  8.  
  9.  
  10. #import "MEPingSites.h"
  11.  
  12.  
  13. NSString *MEPingSiteURLs = @"pingSiteURLs";
  14.  
  15.  
  16. @interface MEPingSites (Private)
  17. -(void)readPingSitesFromPrefs;
  18. -(void)writePingSitesToPrefs;
  19. @end
  20.  
  21.  
  22. @implementation MEPingSites
  23.  
  24.  
  25. +(id)sharedController {
  26.     static id gMyInstance = nil;
  27.     if (gMyInstance == nil)
  28.         gMyInstance = [[self alloc] init];
  29.     return (gMyInstance);
  30.     } /*sharedController*/
  31.     
  32.     
  33. -(id)init {
  34.     self = [super init];
  35.     if (self)
  36.         [self readPingSitesFromPrefs];
  37.     return (self);
  38.     } /*init*/
  39.     
  40.  
  41. -(void)dealloc {
  42.     [pingSites release];
  43.     [super dealloc];
  44.     } /*dealloc*/
  45.     
  46.     
  47. #pragma mark Prefs
  48.  
  49. -(void)readPingSitesFromPrefs {
  50.  
  51.     NSArray *tempArray = [[NSUserDefaults standardUserDefaults] objectForKey: MEPingSiteURLs];
  52.     NSMutableArray *tempMutableArray = [NSMutableArray arrayWithCapacity: 10];
  53.     
  54.     if ((tempArray == nil) || ([tempArray count] < 1)) { /*Upgrade to use variable array of ping sites*/
  55.         [tempMutableArray addObject: @"http://ping.blo.gs/"];
  56.         [tempMutableArray addObject: @"http://rpc.technorati.com/rpc/ping"];
  57.         [tempMutableArray addObject: @"http://rpc.weblogs.com/RPC2"];
  58.         } /*if*/
  59.     else
  60.         tempMutableArray = [[tempArray mutableCopy] autorelease];
  61.         
  62.     [self setPingSites: tempMutableArray];
  63.     } /*readPingSitesFromPrefs*/
  64.     
  65.  
  66. -(void)writePingSitesToPrefs {
  67.     [[NSUserDefaults standardUserDefaults] setObject: pingSites forKey: MEPingSiteURLs];
  68.     } /*writePingSitesToPrefs*/
  69.     
  70.     
  71. #pragma mark Accessors
  72.  
  73. -(NSMutableArray*)pingSites {
  74.     return (pingSites);
  75.     } /*pingSites*/
  76.  
  77.  
  78. -(void)setPingSites:(NSMutableArray*)anArray {
  79.     [pingSites autorelease];
  80.     pingSites = [anArray retain];
  81.     [self writePingSitesToPrefs];
  82.     } /*setPingSites:*/
  83.  
  84.  
  85. @end
  86.